﻿Imports KOR.Helpers

Namespace BL
    Public Module Categories


#Region "Categories_DML"
        Public Function InsertCategory(dict As Dictionary(Of String, Object)) As Integer
            Return DDA.Insert("Categories", dict)
        End Function

        Public Function UpdateCategory(dict As Dictionary(Of String, Object), CategoryID As Integer) As Integer
            Return DDA.Update("Categories", dict, "CategoryID=" & CategoryID)
        End Function

        Public Function DeleteCategory(ByVal CategoryID As Integer) As Integer
            Return DDA.Delete("Categories", "CategoryID=" & CategoryID, False)
        End Function
#End Region

#Region "Categories_Selection"
        Public Function GetAllCategories() As IDataReader
            Dim sql As String = "SELECT * FROM Categories Order By CategoryID DESC"
            Return DDA.SelectData(sql)
        End Function

        Public Function GetCategories(searchFor As String, criteria As String, startRowIndex As Integer, maximumRows As Integer, SortBy As String) As IDataReader
            Dim sql As String
            sql = "SELECT * FROM Categories "

            If SortBy = "" Then SortBy = " CreatedDate Desc"

            Return DDA.SelectDataPaginated(sql, startRowIndex, maximumRows, SortBy)
        End Function

        Public Function CategoriesCount(searchFor As String, criteria As String) As Integer
            Dim sql As String
            sql = "SELECT * FROM Categories "
            Return DDA.SelectDataCount(sql)
        End Function
#End Region

    End Module
End Namespace

